@echo off
REM ============================================
REM Mall 微服务项目 - 订单流程测试脚本 (Windows)
REM ============================================

echo ==========================================
echo Mall 微服务订单流程测试
echo ==========================================
echo.

echo 1. 检查服务状态...
echo.

REM 检查订单服务
echo 检查订单服务 (8081)...
curl -s http://localhost:8081/api/orders/health >nul 2>&1
if %errorlevel% equ 0 (
    echo [OK] 订单服务运行中
) else (
    echo [ERROR] 订单服务未启动
    echo 请先启动 order-service
    exit /b 1
)

echo.
echo 2. 创建测试订单...
echo.

REM 创建订单
curl -X POST http://localhost:8081/api/orders ^
  -H "Content-Type: application/json" ^
  -d "{\"userId\": 1001, \"shippingAddress\": \"北京市朝阳区xxx街道xxx号\", \"remark\": \"测试订单\", \"items\": [{\"skuId\": 1, \"skuName\": \"iPhone 15 Pro 256GB\", \"price\": \"7999.00\", \"quantity\": 1}, {\"skuId\": 3, \"skuName\": \"AirPods Pro 2\", \"price\": \"1899.00\", \"quantity\": 2}]}" ^
  -o order-response.json

echo.
echo [OK] 订单创建成功
echo.

echo 订单详情:
type order-response.json
echo.

echo.
echo 3. 等待订单处理 (约 3-5 秒)...
timeout /t 5 /nobreak >nul

echo.
echo 4. 测试完成！
echo.
echo 提示:
echo - 查看 order-response.json 文件获取订单编号
echo - 使用订单编号查询订单状态: curl http://localhost:8081/api/orders/{orderNo}
echo - 查看各服务日志了解详细处理过程
echo - 访问 AKHQ (http://localhost:9001) 查看 Kafka 消息
echo.

pause

